package com;

import com.Utils.BaseUtils;

import java.lang.reflect.Field;

public class Main {
    public static void main(String[] args) {
        testFunction();
        alreadyTest();
    }

    private static void alreadyTest() {
        double dpi = BaseUtils.getDpi();
        System.out.print("计算出手机的DPI(PPI)为： " + dpi);
        // 除数
        int[] divisor = BaseUtils.getIntArr(-2, 2, -3, 3);
        // 被除数
        int[] dividend = BaseUtils.getIntArr(-2, 2);
        for (int k : divisor) {
            for (int i : dividend) {
                System.out.println(k + " % " + i + " = " + (k % i));
            }
        }
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9};
        System.out.println(arr.length + "\t" + arr[3]);
    }

    /**
     * a 同时 = 1,2,3
     */
    private static void testFunction() {
        try {
            Class<?> cache = Integer.class.getDeclaredClasses()[0];
            Field c = cache.getDeclaredField("cache");
            c.setAccessible(true);
            Integer[] array = (Integer[]) c.get(cache);
            // array[129] is 1
            array[130] = array[129];

            // Set 2 to be 1
            array[131] = array[129];

            // Set 3 to be 1 Integer a = 1;
            int a = 1;
            if (a == (Integer) 1 && a == (Integer) 2 && a == (Integer) 3) {
                System.out.println("Success\t a = " + a);
            }
            System.out.println("结束！");
        } catch (NoSuchFieldException | IllegalAccessException ex) {
            ex.printStackTrace();
        }
    }
}
